<?php
namespace Home\Model;
//物品基础属性
class Taskgoods extends Container{
    protected $redis;
    protected $user;
    protected $type ;
    protected $index ;
    protected $username ;
    protected $item_max;
    public function __construct($user){
        //数据集
        parent::__construct($user, "warehouse");
        //单品数量限制
        $this->item_max = 60;
    }
    //加
    public function add($name, $amount, $pre = false){
        $total = $this->redis->hGet($this->class.$this->username, $name);
        if($total + $amount > $this->item_max) return error('任务物品没有充足的空间');
        if($pre) return true;
        //统计
        $this->hIncrBy($name.'_count', $amount);
        //实际是放入仓库了,但是不计数量
        return $this->redis->hIncrBy($name, $amount);
    }

} 